
export const DAY_MUNIS = 24 * 60 * 60 * 1000;
export const BASE_OPERATE_PRIORITY = {
    '+': 50,
    "-": 50,
    "*": 60,
    "/": 60,
    "%": 60,
    "**": 70,
    "!": 80,
    "==": 90,
    "!=": 90,
    ">": 90,
    "<": 90,
    ">=": 90,
    "<=": 90
}
export const BASE_OPERATE: OperateSymbol[] = [
    '+','-','*','/','==','!=','!','>',">=",'<','<=', '**', '%'
];
export type OperateSymbol = (keyof typeof BASE_OPERATE_PRIORITY)
export interface IError {
    info: any;
    toString: () => string;
}
export interface IFormulaItem {
    type: string;
}
export interface IPositionFullRow extends IFormulaItem {
    type: 'rowPosition',
    value: number;
    /**
     * true 相对 false 绝对
     */
    isRelative: boolean;
}
export interface IPositionFullCol extends IFormulaItem {
    type: 'colPosition',
    value: number;
    isRelative: boolean;
}
export interface IPosition extends IFormulaItem{
    type: 'position'
    row: number;
    rowIsRelative: boolean;
    col: number;
    colIsRelative: boolean;
}
export type IAllPosition = IPositionFullRow|IPositionFullCol|IPosition;
export interface IOperate extends IFormulaItem {
    type: 'operate';
    value: OperateSymbol;
}
export interface IExcelValue {
    rangeId?: string;
    range?: string;
    row?: number;
    col?: number;
}
export interface IValueString extends IFormulaItem, IExcelValue {
    type: 'value';
    dataType: 'string';
    value: string;
    range?: string;
}
export interface IValueNumber extends IFormulaItem, IExcelValue {
    type: 'value';
    dataType: 'number';
    value: number
}
export interface IValueBoolean extends IFormulaItem, IExcelValue {
    type: 'value';
    dataType: 'boolean';
    value: boolean;
}
export type IPositionValue =  (IValueString | IValueNumber | IValueBoolean) & {
    row: number;
    col: number;
}
export interface IValueRange extends IFormulaItem {
    type: 'value',
    dataType: 'range',
    value: {
        row: number;
        col: number;
        rowspan: number;
        colspan: number;
        [Symbol.iterator]: () => {next: () => {done: boolean; value: any}}
    }
}
export interface IValueEmpty extends IFormulaItem {
    type: 'empty';
}
export type IValueBase = IValueString | IValueNumber | IValueBoolean | IValueEmpty;
export type  IValue = IValueString | IValueNumber | IValueBoolean | IValueRange;
export interface IBrackets extends IFormulaItem {
    type: 'brackets';
    value: 'left'|'right'
}
export interface IFunction extends IFormulaItem {
    type: 'function';
    value: string;
}
export interface IPlusMinus extends IFormulaItem {
    type: 'plusMinus',
    value: 'plus'|'minus'
}
export interface IFormulaError extends IFormulaItem  {
    type: 'error';
    msg: string;
}
export interface IKeywords extends IFormulaItem {
    type: 'keyworks';
    value: string;
}
export interface ISpecial extends IFormulaItem {
    type: 'special',
    value: ':'|','
}
export interface ICollect extends IFormulaItem {
    type: 'collect',
    value: '{'|'}'
}
export interface ILink extends IFormulaItem {
    type: 'link',
    value: '&'
}
export interface IRange extends IFormulaItem {
    type: 'range';
    value: {
        getValues: () => IValueBase[],
        getMatrixValues: () => IValueBase[][]
    }
}
// export interface IValueBoolean extends IFormulaItem {
//     type: 'value',
//     dataType: 'boolean';
//     value: boolean;
// }
export type TAllTypes = IPosition | IOperate | IValueString | IValueNumber 
| IValueBoolean | IBrackets | IFunction | IPositionFullRow|IPositionFullCol|IPlusMinus
|IFormulaError|IKeywords|ISpecial|IRange|IValueRange|ICollect|ILink| IValueEmpty;
/**
 * '#div/0!' 当公式被零除时，将产生错误值#div/0！
 * '#N/A' 当在函数或公式中没有可用的数值时，将产生错误值#N/A
 * '#NAME?' 在公式中使用了Microsoft Excel不能识别的文本
 * '#NULL!' 试图为两个并不相交的区域指定交叉点时，将产生以上错误
 * '#NUM!' 当公式或函数中某些数字有问题时，将产生该错误信息
 * '#REF!' 当单元格引用无效时，将产生该错误信息
 * '#value!' 当使用错误的参数或运算对象类型时，或当自动更改公式功能不能更正公式时，将产生该错误信息
 */
export const ErrorInfo = {
    '#DIV/0!': '当公式被零除时，将产生错误值#div/0!',
    '#N/A': '当在函数或公式中没有可用的数值时，将产生错误值#N/A',
    '#NAME?': '在公式中使用了Microsoft Excel不能识别的文本',
    '#NULL!': '试图为两个并不相交的区域指定交叉点时，将产生以上错误',
    '#NUM!': '当公式或函数中某些数字有问题时，将产生该错误信息',
    '#REF!': '当单元格引用无效时，将产生该错误信息',
    '#VALUE!': '当使用错误的参数或运算对象类型时，或当自动更改公式功能不能更正公式时，将产生该错误信息',
    '#UNKOWN!': '未知错误',
    "#UNSUPPORT": '未支持'
}
export type IFunctionCalculate = {
    [key: string]: (args: TAllTypes[]) => TAllTypes[];
}
export interface IGetRangeValues {
    getRangeValues(range: TRange): (null|string|number|boolean)[][];
}

export interface IColData {
    value: IValueNumber|IValueString|IValueBoolean|null|undefined
}

export interface IRow {
    cells: IColData[];
}

export type TData = IRow[];